﻿#pragma once


#include <QDialog>
#include <QPushButton>
#include "QListView"
#include "QStringListModel"
#include "QFileDialog"
#include "QMessageBox"
#include "QApplication"
#include "QVBoxLayout"
#include <QDesktopWidget>
#include <QLibrary>
#include <QApplication>
#include <QLabel>
#include <QComboBox>
#include "QListView"
#include "QStringListModel"
#include "QLineEdit"
#include "QSpinBox"
#include "QDoubleSpinBox"
#include <QSettings>

#include "commonfunction.h"

#include "halcon_opencv.h"

using namespace std;



#include "qt_graphics_view.h"

class FunctionBlobSize :public QDialog
{
public:
    QSettings* m_qsettings;
    Mat m_image ,m_image_show;
    QString m_section   = "";

    QtQGraphicsView* m_view ;


    QLabel* m_qlabel_row1;
    QSpinBox* m_qspinbox_row1;

    QLabel* m_qlabel_row2;
    QSpinBox* m_qspinbox_row2;

    QLabel* m_qlabel_column1;
    QSpinBox* m_qspinbox_column1;

    QLabel* m_qlabel_column2;
    QSpinBox* m_qspinbox_column2;






	
	QSpinBox * m_qspinbox_standard_size;
	int m_standard_size = 0;

    QSpinBox * m_qspinbox_standard_length;
    int m_standard_length = 0;

    
	QDoubleSpinBox * m_qspinbox_ratio;
    double m_ratio = 0;

	
	QSpinBox* m_qspinbox_threshold_gray;
	int m_standard_threshold_gray = 0;

    
    QSpinBox* m_qspinbox_error_size;
    int m_error_size=0;



	QPushButton* m_pushbutton_show_orign_image;
    QPushButton* m_pushbutton_detection;
    QPushButton* m_pushbutton_save_parameter;
    QPushButton* m_pushbutton_return;

    QLabel* m_qlabel_message;



    int m_size;


    HObject m_region;

    HObject m_error_region;

	double value_standard=0;

    HObject image_in;


    

public:
    explicit FunctionBlobSize(QDialog *parent = nullptr, QSettings* qsettings = nullptr,QString section="", int camera_index = 0) ;
    ~FunctionBlobSize() ;
    void detectionImage();
    bool detection( HObject image_in, QString& message);
    void draw( Mat image_in,Mat& image_out);
    void loadParameter();
    void saveParameter();
    bool showDialog();
};
#pragma execution_character_set("utf-8")
